<?php
/**
 * Created by PhpStorm.
 * User: liubin
 * Date: 16/10/27
 * Time: 下午 16:20
 */

namespace api\Model;

use Think\Model;

class LiveEntityModel extends Model
{
    function __construct() {
        $this->model = M('LiveEntity');
        $this->model1 = M('LiveVideo');
        $this->model2 = M('CustEntity');
    }

    public function getlive($condition = array()) {
        $data = $this->model->where(array('live_keys' => $condition))->order('live_id desc')->field('live_title,live_id')->find();
        $data = $data ? $data : array();
        return $data;
    }


    //销毁聊天室 更新时间
    public function getliveinfo($condition = array(),$field=array()) {
        $data = $this->model->where($condition)->save($field);
        return $data;
    }


    //聊天室信息
    public function liveinfo($condition = array(),$field=array()) {
        $data = $this->model->where($condition)->getField($field);
        $data = $data ? $data : array();
        return $data;
    }

    //聊天室信息
    public function liveinfos($condition = array()) {
        $data = $this->model->where($condition)->find();
        $data = $data ? $data : array();
        return $data;
    }


    public function getreb($condition = array(),$page=1,$pergage = 10) {
       // $data = $this->model1->where($condition)->page($page,$pergage)->order('add_at desc')->select();
      //  $data = $data ? $data : array();
        $data = M('LiveVideo l')->join('mcf_cust_entity c ON l.cust_id = c.cust_id')->where($condition)->field('l.*,c.cust_img,nickname')->page($page,$pergage)->order('add_at desc')->select();
        //echo M('LiveVideo l')->join('mcf_cust_entity c ON l.cust_id = c.cust_id')->_sql();exit;
        return $data;
    }

    public function getreb1($condition = array(),$page=1,$pergage = 10) {
          $data = $this->model1->where($condition)->page($page,$pergage)->order('add_at desc')->select();
          $data = $data ? $data : array();

        return $data;
    }


}